package activitytest.example.com.application.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.CheckBox;
import android.widget.RelativeLayout;
import android.widget.TextView;

import activitytest.example.com.application.R;

/**
 * Created by zhanyihong on 2017/12/5.
 */

public class SettingItemView extends RelativeLayout {
    private CheckBox cb_box;
    private  TextView tv_des;

    public SettingItemView(Context context) {
        this(context, null);
    }

    public SettingItemView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SettingItemView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        View.inflate(context, R.layout.setting_item_view, this);
        TextView tv_title = (TextView) findViewById(R.id.tv_title);

       tv_des = (TextView) findViewById(R.id.tv_des);
        cb_box = (CheckBox) findViewById(R.id.cd_box);

//        initAttrs();

//        cb_box.isChecked()
    }

    private void initAttrs(AttributeSet attrs) {

    }

    public boolean isCheck() {
        return cb_box.isChecked();
    }
    public void setCheck(boolean isCheck){
        cb_box.setChecked(isCheck);
        if(isCheck){
            tv_des.setText("自动更新已开启");
        }else {
            tv_des.setText("自动更新已关闭");
        }
    }

}
